import { Equal, Expect } from "@type-challenges/utils";
type TransformUppercaseLetter<S extends string> =
  S extends `${infer L}${infer R}`
    ? L extends Lowercase<L>
      ? `${L}${TransformUppercaseLetter<R>}`
      : `-${Lowercase<L>}${TransformUppercaseLetter<R>}`
    : S;
type HandleFirst<S extends string> = S extends `${infer L}${infer R}`
  ? `${Lowercase<L>}${R}`
  : S;
type KebabCase<S extends string> = TransformUppercaseLetter<HandleFirst<S>>;
type cases = [
  Expect<Equal<KebabCase<"FooBarBaz">, "foo-bar-baz">>,
  Expect<Equal<KebabCase<"fooBarBaz">, "foo-bar-baz">>,
  Expect<Equal<KebabCase<"foo-bar">, "foo-bar">>,
  Expect<Equal<KebabCase<"foo_bar">, "foo_bar">>,
  Expect<Equal<KebabCase<"Foo-Bar">, "foo--bar">>,
  Expect<Equal<KebabCase<"ABC">, "a-b-c">>,
  Expect<Equal<KebabCase<"-">, "-">>,
  Expect<Equal<KebabCase<"">, "">>,
  Expect<Equal<KebabCase<"😎">, "😎">>
];
